<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/common/global.jsp"%>
<%@ include file="/common/include_common.jsp"%>
<html lang="zh-cn">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>密码修改</title>
</head>
<body>
	<form id="dataForm" method="post">
		<div class="container col-xs-11"
			style="margin-top: 30px; margin-left: 50px; display: table;">

			<div class="row" style="margin-top: 10px; margin-bottom: 10px;">
				<div class="col-xs-4 text-left"
					style="background-color: #F5F5F5; line-height: 26px; vertical-align: middle;">
					<label style="margin-top: 5px; font-size: 14px; color: grey;">用户名：</label>
				</div>
				<div class="col-xs-7">
					<div class="form-group">
						<input type="text" id="username" name="username"
							value="" class="form-control"
							placeholder=""   readOnly="readonly"/>
					</div>
				</div>
			</div>
			<div class="row" style="margin-top: 10px; margin-bottom: 10px;">
				<div class="col-xs-4 text-left"
					style="background-color: #F5F5F5; line-height: 26px; vertical-align: middle;">
					<label style="margin-top: 5px; font-size: 14px; color: grey;">原始密码：</label>
				</div>
				<div class="col-xs-7">
					<div class="form-group">
						<input type="password" id="oldPassword" name="oldPassword"
							value="" class="form-control"
							placeholder="" />
					</div>
				</div>
			</div>
			<div class="row" style="margin-top: 10px; margin-bottom: 10px;">
				<div class="col-xs-4 text-left"
					style="background-color: #F5F5F5; line-height: 26px; vertical-align: middle;">
					<label style="margin-top: 5px; font-size: 14px; color: grey;">新密码：</label>
				</div>
				<div class="col-xs-7">
					<div class="form-group">
						<input type="password" id="newPassword" name="newPassword"
							value="" class="form-control"
							placeholder="" />
					</div>
				</div>
			</div>
			<div class="row" style="margin-top: 10px; margin-bottom: 10px;">
				<div class="col-xs-4 text-left"
					style="background-color: #F5F5F5; line-height: 26px; vertical-align: middle;">
					<label style="margin-top: 5px; font-size: 14px; color: grey;">确认密码：</label>
				</div>
				<div class="col-xs-7">
					<div class="form-group">
						<input type="password" id="confirmPassword" name="confirmPassword"
							value="" class="form-control" />
					</div>
				</div>
			</div>
			<div class="row" style="margin-top: 10px; margin-bottom: 10px;"
				align="center">
				<button id="save-btn" class="waves-effect btn btn-info"
					style="margin-left: 10px;" type="button" href="javascript:;">
					<i class="zmdi zmdi-save"></i> 保存
				</button>
			</div>

		</div>
	</form>
</body>
<script type="text/javascript">

$(function() {
	//表单效验
	$('form').bootstrapValidator({
		//container : "tooltip",
		container : "popover",
		message : 'This value is not valid',
		feedbackIcons : {
			valid : 'glyphicon glyphicon-ok',
			invalid : 'glyphicon glyphicon-remove',
			validating : 'glyphicon glyphicon-refresh'
		},
		fields : {
			'oldPassword' : {
				validators : {
					notEmpty : {
						message : '原始密码不能为空'
					}/* ,
					regexp : {
						regexp : /^[a-zA-Z0-9_/\.]+$/,
						message : '请输入正确的路径地址'
					} */
				}
			},
			'newPassword' : {
				validators : {
					notEmpty : {
						message : '新密码不能为空'
					}/* ,
					regexp : {
						regexp : /^[a-zA-Z0-9_/\.]+$/,
						message : '请输入正确的路径地址'
					} */
				}
			},
			'confirmPassword' : {
				validators : {
					notEmpty : {
						message : '确认密码不能为空'
					}/* ,
					regexp : {
						regexp : /^[a-zA-Z0-9_/\.]+$/,
						message : '请输入正确的路径地址'
					} */
				}
			}
		}
	});
	
	$.ajax({  url : '${pageContext.request.contextPath}/common/user/getPer',
		
		data:{},
		
		 cache : false,
		
		async : false,
		
		type : "POST",
		
		 dataType : 'json',
		
		 success : function (data){
			 if(data.status=="0"){
				 $("#username").val(data.res.userCode);
			 }
						//alert("dddddddddd");
		},
		error:function (data){
			debugger;
			alert("ddddddd");
		}
		
   });
	//	debugger;

	$('#save-btn').click(function() {
		debugger;
	  var newPassword =$("#newPassword").val();	
	  var oldPassword =$("#oldPassword").val();	
	  var confirmPassword =$("#confirmPassword").val();	
	  if(newPassword !=confirmPassword){
		  $.alert({
			    title: '温馨提示',
			    content: '两次输入的密码不一致！',
			});
		  return false;
	  }
		// 获取form表单中的值
		$.post('${pageContext.request.contextPath}/common/user/updatePerPassword', { 
			'newPassword' : newPassword,
			'oldPassword' : oldPassword,
			'confirmPassword' : confirmPassword
		}, function(data) {
			$.alert({
				title: '温馨提示',
				content: data.msg,
				autoClose: 'ok|3000',
				buttons: {
					ok: {
						text:"确定"
					}
				}
			});
		});
	});
});
	
</script>
</html>